package com.netease.pris.persist;

import com.db4o.ObjectSet;
import com.netease.pris.meta.UserProfile;

/**
 * 
 * @author Administrator
 * 
 */
public class UserProfilePersist extends BasePersist {

	private static UserProfilePersist persist = new UserProfilePersist();

	private UserProfilePersist() {
	}

	public static UserProfilePersist getPersist() {
		return persist;
	}

	public void add(UserProfile profile) {
		getContainer().store(profile);
	}

	public void update(UserProfile profile) {
		getContainer().store(profile);
	}

	public UserProfile queryById(String id) {
		UserProfile profile = new UserProfile();
		profile.setUserId(id);
		ObjectSet<UserProfile> profiles = getContainer().queryByExample(profile);
		if (profiles != null && profiles.size()>0) {
			return profiles.get(0);
		}
		return null;
	}

	public void delete(UserProfile profile) {
		getContainer().delete(profile);
	}

	public ObjectSet<UserProfile> getAll() {
		return getContainer().query(UserProfile.class);
	}

	public ObjectSet<UserProfile> query(UserProfile host) {
		return getContainer().queryByExample(host);
	}
}
